package com.xin.data.simbapesa.utils;

import android.content.Context;
import android.text.TextUtils;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.xin.data.simbapesa.SimbaApp;
import com.xin.data.simbapesa.api.U;
import com.xin.data.simbapesa.obj.SimbaAccInfo;
import com.xin.data.simbapesa.obj.SimbaAccountItem;
import com.xin.data.simbapesa.obj.SimbaAccout;
import com.xin.data.simbapesa.obj.SimbaAmountIsUpInfo;
import com.xin.data.simbapesa.obj.SimbaAppInfo;
import com.xin.data.simbapesa.obj.SimbaApplyDetailInfo;
import com.xin.data.simbapesa.obj.SimbaBirthCouponsInfo;
import com.xin.data.simbapesa.obj.SimbaChatInfo;
import com.xin.data.simbapesa.obj.SimbaContact;
import com.xin.data.simbapesa.obj.SimbaCouponsInfo;
import com.xin.data.simbapesa.obj.SimbaCouponsItem;
import com.xin.data.simbapesa.obj.SimbaDetailInfo;
import com.xin.data.simbapesa.obj.SimbaDetailItemInfo;
import com.xin.data.simbapesa.obj.SimbaInfoData;
import com.xin.data.simbapesa.obj.SimbaLogin;
import com.xin.data.simbapesa.obj.SimbaMessageInfo;
import com.xin.data.simbapesa.obj.SimbaOfflineRepayment;
import com.xin.data.simbapesa.obj.SimbaOrderRepayInfo;
import com.xin.data.simbapesa.obj.SimbaOrderRepayState;
import com.xin.data.simbapesa.obj.SimbaPersonal;
import com.xin.data.simbapesa.obj.SimbaPlatformNotice;
import com.xin.data.simbapesa.obj.SimbaProductsAmount;
import com.xin.data.simbapesa.obj.SimbaRepayInfo;
import com.xin.data.simbapesa.obj.SimbaScoreInfo;
import com.xin.data.simbapesa.obj.SimbaUpdateInfo;
import com.xin.data.simbapesa.obj.SimbaUserProcess;
import com.xin.data.simbapesa.obj.SimbaValueInfo;
import com.xin.data.simbapesa.obj.SimbaWalletChannel;
import com.xin.data.simbapesa.obj.SimbaWork;


import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

public class JsonParse {


    public static String getMsg(Context context, String json) {
        String msg;
        JSONObject jsonObject;
        try {
            jsonObject = new JSONObject(json);
            if (!jsonObject.isNull("msg")) {
                msg = jsonObject.getString("msg");
                return msg;
            }
        } catch (JSONException ignored) {
        }
        return "";
    }

    public static boolean getCode(String json) {
        JSONObject jsonObject;
        try {
            jsonObject = new JSONObject(json);
            if (!jsonObject.isNull("code") && jsonObject.getInt("code") == 0) {
                return true;
            }
        } catch (JSONException ignored) {
        }
        return false;
    }

    public static String getTimeJson(String json) {
        JSONObject jsonObject;
        String data = "";
        try {
            jsonObject = new JSONObject(json);
            if (!jsonObject.isNull("data")) {
                data = jsonObject.getString("data");
            }
        } catch (JSONException ignored) {
        }
        return data;
    }

    public static SimbaAppInfo appInfoJson2Obj(String json) {
        SimbaAppInfo appInfo = null;
        try {
            JSONObject jsonObject = new JSONObject(json);
            if (!jsonObject.isNull("obj") || !jsonObject.isNull("data")) {
                JSONObject data;
                if (!jsonObject.isNull("data")) {
                    data = jsonObject.getJSONObject("data");
                } else {
                    data = jsonObject.getJSONObject("obj");
                }
                if (!data.isNull("customize")) {
                    JSONObject customize = jsonObject.getJSONObject("obj").getJSONObject("customize");
                    appInfo = new SimbaAppInfo();
                    if (!customize.isNull("homeAmount")) {
                        appInfo.setHomeAmount(customize.getString("homeAmount"));
                    }
                    if (!customize.isNull("mobile")) {
                        appInfo.setMobile(customize.getString("mobile"));
                    }
                    if (!customize.isNull("email")) {
                        appInfo.setEmail(customize.getString("email"));
                    }
                    if (!customize.isNull("usageStatsPermission")) {
                        appInfo.setUsageStatsPermission(customize.getString("usageStatsPermission"));
                    }
                    if (!customize.isNull("repayImportant")) {
                        appInfo.setRepayImportant(customize.getString("repayImportant"));
                    }
                    if (!customize.isNull("transferDelayImportant")) {
                        appInfo.setTransferDelayImportant(customize.getString("transferDelayImportant"));
                    }
                    if (!customize.isNull("privacyUrl")) {
                        appInfo.setPrivacyUrl(customize.getString("privacyUrl"));
                    }
                    if (!customize.isNull("walletChannels")) {
                        List<SimbaWalletChannel> list = new ArrayList<>();
                        JSONArray array = customize.getJSONArray("walletChannels");
                        for (int i = 0; i < array.length(); i++) {
                            SimbaWalletChannel walletChannelInfo = new SimbaWalletChannel();
                            JSONObject w_jsonObject = array.getJSONObject(i);
                            if (!w_jsonObject.isNull("logo")) {
                                walletChannelInfo.setLogo(w_jsonObject.getString("logo"));
                            }
                            if (!w_jsonObject.isNull("value")) {
                                walletChannelInfo.setValue(w_jsonObject.getString("value"));
                            }
                            if (!w_jsonObject.isNull("desc")) {
                                walletChannelInfo.setDesc(w_jsonObject.getString("desc"));
                            }
                            list.add(walletChannelInfo);
                        }
                        for (SimbaWalletChannel item : list) {
                            if (U.isCameroon) {
                                if (item.getDesc().equals("MTN")) {
                                    item.setLogo("https://divoire.s3.af-south-1.amazonaws.com/pic/33149e4bbeb2466dac7665034f9e84e6.jpg");
                                }
                                if (item.getDesc().equals("Orange Money") || item.getDesc().equals("ORANGE")) {
                                    item.setLogo("https://divoire.s3.af-south-1.amazonaws.com/app/Orangemoneylogo.png");
                                }
                            }
                        }
                        appInfo.setWalletChannels(list);
                    }
                    if (!customize.isNull("rejectPeriod")) {
                        appInfo.setRejectPeriod(customize.getString("rejectPeriod"));
                    }
                    if (!customize.isNull("repayType")) {
                        appInfo.setRepayType(customize.getString("repayType"));
                    }
                    if (!customize.isNull("permissions") && !customize.getJSONObject("permissions").isNull("permission")) {
                        String permission = customize.getJSONObject("permissions").getString("permission");
                        Gson gson = new Gson();
                        String[] list = gson.fromJson(permission, String[].class);
                        appInfo.setPermission(list);
                    }
                    if (!customize.isNull("permissions") && !customize.getJSONObject("permissions").isNull("home")) {
                        String home = customize.getJSONObject("permissions").getString("home");
                        Gson gson = new Gson();
                        String[] list = gson.fromJson(home, String[].class);
                        appInfo.setHome(list);
                    }
                    if (!customize.isNull("usageStatsDays")) {
                        appInfo.setUsageStatsDays(customize.getString("usageStatsDays"));
                    }
                    if (!customize.isNull("showSysReview")) {
                        appInfo.setShowSysReview(customize.getString("showSysReview"));
                    }
                    if (!customize.isNull("offlineRepayment")) {
                        JSONObject o_jsonObject = customize.getJSONObject("offlineRepayment");
                        SimbaOfflineRepayment offlineRepayment = new SimbaOfflineRepayment();
                        if (!o_jsonObject.isNull("bankCode")) {
                            offlineRepayment.setBankCode(o_jsonObject.getString("bankCode"));
                        }
                        if (!o_jsonObject.isNull("accountName")) {
                            offlineRepayment.setAccountName(o_jsonObject.getString("accountName"));
                        }
                        if (!o_jsonObject.isNull("accountNo")) {
                            offlineRepayment.setAccountNo(o_jsonObject.getString("accountNo"));
                        }
                        if (!o_jsonObject.isNull("bankName")) {
                            offlineRepayment.setBankName(o_jsonObject.getString("bankName"));
                        }
                        appInfo.setOfflineRepayment(offlineRepayment);
                    }
                    if (!customize.isNull("afKey")) {
                        appInfo.setAfKey(customize.getString("afKey"));
                    }
                    if (!customize.isNull("accList")) {
                        JSONArray array = customize.getJSONArray("accList");
                        List<SimbaAccInfo> list = new ArrayList<>();
                        for (int i = 0; i < array.length(); i++) {
                            JSONObject a_jsonObject = array.getJSONObject(i);
                            SimbaAccInfo info = new SimbaAccInfo();
                            if (!a_jsonObject.isNull("accM")) {
                                info.setAccM(a_jsonObject.getString("accM"));
                            }
                            if (!a_jsonObject.isNull("accTk")) {
                                info.setAccTk(a_jsonObject.getString("accTk"));
                            }
                            if (!a_jsonObject.isNull("accUid")) {
                                info.setAccUid(a_jsonObject.getString("accUid"));
                            }
                            list.add(info);
                        }
                        appInfo.setAccList(list);
                    }
                    if (!customize.isNull("accListV2")) {
                        JSONArray array = customize.getJSONArray("accListV2");
                        List<SimbaAccInfo> list = new ArrayList<>();
                        for (int i = 0; i < array.length(); i++) {
                            JSONObject a_jsonObject = array.getJSONObject(i);
                            SimbaAccInfo info = new SimbaAccInfo();
                            if (!a_jsonObject.isNull("accM")) {
                                info.setAccM(a_jsonObject.getString("accM"));
                            }
                            if (!a_jsonObject.isNull("accTk")) {
                                info.setAccTk(a_jsonObject.getString("accTk"));
                            }
                            if (!a_jsonObject.isNull("accUid")) {
                                info.setAccUid(a_jsonObject.getString("accUid"));
                            }
                            list.add(info);
                        }
                        appInfo.setAccListV2(list);

                    }
                    if (!customize.isNull("rejectAfterDays")) {
                        appInfo.setRejectAfterDays(customize.getString("rejectAfterDays"));
                    }
                    if (!customize.isNull("customerServiceDate")) {
                        appInfo.setCustomerServiceDate(customize.getString("customerServiceDate"));
                    }
                    if (!customize.isNull("userlv")) {
                        if (!TextUtils.isEmpty(U.URL_PHONE) && !TextUtils.isEmpty(PhoneUtils.isAccM(U.URL_PHONE))) {

                        } else {
                            appInfo.setUserlv(NumUtils.str2Int(customize.getString("userlv")));
                            SpUtils.save_int(SimbaApp.getInstance(), SpUtils.KEY_VIP, appInfo.getUserlv());
                        }
                    }
                    if (!customize.isNull("deleteDate")) {
                        appInfo.setDeleteDate(customize.getString("deleteDate"));
                    }

                    if (!customize.isNull("couponsInfo") && customize.getString("couponsInfo").startsWith("[")) {
                        try {
                            JSONArray array = customize.getJSONArray("couponsInfo");
                            if (array.length() > 0) {
                                SimbaCouponsInfo info = new SimbaCouponsInfo();
                                List<SimbaCouponsItem> list = new ArrayList<>();
                                for (int i = 0; i < array.length(); i++) {
                                    JSONObject beanJsonObject = array.getJSONObject(i);
                                    SimbaCouponsItem beanInfo = new SimbaCouponsItem();
                                    if (!beanJsonObject.isNull("couponGhs")) {
                                        beanInfo.setCouponGhs(beanJsonObject.getString("couponGhs"));
                                    }
                                    if (!beanJsonObject.isNull("expireDate")) {
                                        beanInfo.setExpireDate(beanJsonObject.getString("expireDate"));
                                    }
                                    if (!beanJsonObject.isNull("newCouponGhs")) {
                                        beanInfo.setNewCouponGhs(beanJsonObject.getString("newCouponGhs"));
                                    }
                                    beanInfo.initData();
                                    list.add(beanInfo);
                                    info.setCouponsItemList(list);
                                }

                                appInfo.setCouponsInfo(info);
                            }
                        } catch (Exception e) {
                            LogUtil.e("me", "getCouponsInfo->" + e);
                        }
                    }

                    if (!customize.isNull("birthCouponsInfo")) {
                        JSONObject birthCouponsInfoObj = customize.getJSONObject("birthCouponsInfo");
                        SimbaBirthCouponsInfo mBirthCouponsInfo = new SimbaBirthCouponsInfo();
                        if (!birthCouponsInfoObj.isNull("couponGhs")) {
                            mBirthCouponsInfo.setCouponGhs(birthCouponsInfoObj.getString("couponGhs"));
                        }
                        appInfo.setBirthCouponsInfo(mBirthCouponsInfo);
                    }

                    if (!customize.isNull("platformNotice")) {
                        JSONObject noticeObj = customize.getJSONObject("platformNotice");
                        SimbaPlatformNotice platformNotice = new SimbaPlatformNotice();
                        if (!noticeObj.isNull("showNotice")) {
                            platformNotice.setShowNotice(noticeObj.getString("showNotice"));
                        }
                        if (!noticeObj.isNull("noticeInfo")) {
                            platformNotice.setNoticeInfo(noticeObj.getString("noticeInfo"));
                        }
                        if (!noticeObj.isNull("noticeInfo")) {
                            platformNotice.setNoticeInfo(noticeObj.getString("noticeInfo"));
                        }
                        if (!noticeObj.isNull("noticeInfo_sw")) {
                            platformNotice.setNoticeInfoSw(noticeObj.getString("noticeInfo_sw"));
                        }
                        appInfo.setPlatformNotice(platformNotice);
                    }

                    if (!customize.isNull("platformNotice1")) {
                        JSONObject noticeObj = customize.getJSONObject("platformNotice1");
                        SimbaPlatformNotice platformNotice = new SimbaPlatformNotice();
                        if (!noticeObj.isNull("showNotice")) {
                            platformNotice.setShowNotice(noticeObj.getString("showNotice"));
                        }
                        if (!noticeObj.isNull("noticeInfo")) {
                            platformNotice.setNoticeInfo(noticeObj.getString("noticeInfo"));
                        }
                        if (!noticeObj.isNull("noticeInfo")) {
                            platformNotice.setNoticeInfo(noticeObj.getString("noticeInfo"));
                        }
                        if (!noticeObj.isNull("noticeInfo_sw")) {
                            platformNotice.setNoticeInfoSw(noticeObj.getString("noticeInfo_sw"));
                        }
                        appInfo.setPlatformNotice1(platformNotice);
                    }

                    if (!customize.isNull("UpdateInfo")) {
                        JSONObject jsonObject1 = customize.getJSONObject("UpdateInfo");
                        SimbaUpdateInfo updateInfo = new SimbaUpdateInfo();
                        if (!jsonObject1.isNull("forceUpdate")) {
                            updateInfo.setForceUpdate(jsonObject1.getString("forceUpdate"));
                        }
                        if (!jsonObject1.isNull("updateContent")) {
                            updateInfo.setUpdateContent(jsonObject1.getString("updateContent"));
                        }
                        if (!jsonObject1.isNull("updateContent_sw")) {
                            updateInfo.setUpdateContentSw(jsonObject1.getString("updateContent_sw"));
                        }
                        if (!jsonObject1.isNull("updateVer")) {
                            updateInfo.setUpdateVer(jsonObject1.getString("updateVer"));
                        }
                        if (!jsonObject1.isNull("updateCode")) {
                            updateInfo.setUpdateCode(jsonObject1.getInt("updateCode"));
                        }

                        if (!jsonObject1.isNull("ignoreUpdate")) {
                            String ignoreUpdate = jsonObject1.getString("ignoreUpdate");
                            Gson gson = new Gson();
                            Integer[] list = gson.fromJson(ignoreUpdate, Integer[].class);
                            updateInfo.setIgnoreUpdate(list);
                        }

                        appInfo.setUpdateInfo(updateInfo);

                    }

                }
            }

        } catch (JSONException e) {
            return null;
        }
        return appInfo;
    }

    public static void userProcessJson2Obj(String json) {
        JSONObject jsonObject;
        SimbaUserProcess mUserProcessBean = SimbaApp.getInstance().getProcess();
        try {
            jsonObject = new JSONObject(json);
            if (!jsonObject.isNull("data") || !jsonObject.isNull("obj")) {
                if (mUserProcessBean == null) {
                    mUserProcessBean = new SimbaUserProcess();
                    SimbaApp.getInstance().setProcess(mUserProcessBean);
                }
                mUserProcessBean.setApplyStatus("");
                mUserProcessBean.setOrderStatus("");
                JSONObject data;
                if (!jsonObject.isNull("data")) {
                    data = jsonObject.getJSONObject("data");
                } else {
                    data = jsonObject.getJSONObject("obj");
                }
                if (!data.isNull("allStepTitles")) {
                    String allStepTitles = data.getString("allStepTitles");
                    Gson gson = new Gson();
                    String[] list = gson.fromJson(allStepTitles, String[].class);
                    mUserProcessBean.setAllStepTitles(list);
                }
                if (!data.isNull("allSteps")) {
                    String allSteps = data.getString("allSteps");
                    Gson gson = new Gson();
                    String[] list = gson.fromJson(allSteps, String[].class);
                    mUserProcessBean.setAllSteps(list);
                }
                if (!data.isNull("mobile")) {
                    String mobile = data.getString("mobile");
                    LogUtil.e("me", "userProcessJson2Obj mobile->" + mobile);
                    if (!TextUtils.isEmpty(mobile)) {
                        U.URL_PHONE = mobile;
                        SpUtils.save_string(SimbaApp.getInstance(), SpUtils.KEY_PHONE, U.URL_PHONE);
                    }
                }
                if (!data.isNull("personal_info")) {
                    JSONObject personal_info = data.getJSONObject("personal_info");
                    SimbaPersonal personalInfo = new SimbaPersonal();
                    if (!personal_info.isNull("showTopTips")) {
                        personalInfo.setShowTopTips(personal_info.getString("showTopTips"));
                    }
                    if (!personal_info.isNull("topTips")) {
                        personalInfo.setTopTips(personal_info.getString("topTips"));
                    }
                    if (!personal_info.isNull("apiUrl")) {
                        personalInfo.setApiUrl(personal_info.getString("apiUrl"));
                    }
                    if (!personal_info.isNull("dataList")) {
                        JSONArray array = personal_info.getJSONArray("dataList");
                        List<SimbaInfoData> list = new ArrayList<>();
                        for (int i = 0; i < array.length(); i++) {
                            JSONObject a_jsonObject = array.getJSONObject(i);
                            SimbaInfoData info = new SimbaInfoData();
                            if (!a_jsonObject.isNull("isMust")) {
                                info.setIsMust(a_jsonObject.getString("isMust"));
                            }
                            if (!a_jsonObject.isNull("hint")) {
                                info.setHint(a_jsonObject.getString("hint"));
                            }
                            if (!a_jsonObject.isNull("hint_sw")) {
                                info.setHint_sw(a_jsonObject.getString("hint_sw"));
                            }
                            if (!a_jsonObject.isNull("values")) {
                                JSONArray array1 = a_jsonObject.getJSONArray("values");
                                List<SimbaValueInfo> values = new ArrayList<>();
                                for (int j = 0; j < array1.length(); j++) {
                                    JSONObject v_obj = array1.getJSONObject(j);
                                    SimbaValueInfo bean = new SimbaValueInfo();
                                    if (!v_obj.isNull("title")) {
                                        bean.setTitle(v_obj.getString("title"));
                                    }

                                    if (!v_obj.isNull("value")) {
                                        bean.setValue(v_obj.getString("value"));
                                    }
                                    values.add(bean);
                                }
                                info.setValues(values);
                            }
                            if (!a_jsonObject.isNull("action")) {
                                info.setAction(a_jsonObject.getString("action"));
                            }
                            if (!a_jsonObject.isNull("paramName")) {
                                info.setParamName(a_jsonObject.getString("paramName"));
                            }
                            if (!a_jsonObject.isNull("title")) {
                                info.setTitle(a_jsonObject.getString("title"));
                            }
                            if (!a_jsonObject.isNull("title_sw")) {
                                info.setTitle_sw(a_jsonObject.getString("title_sw"));
                            }
                            list.add(info);
                        }
                        personalInfo.setDataList(list);
                    }
                    if (!personal_info.isNull("extDataList")) {
                        JSONArray array = personal_info.getJSONArray("extDataList");
                        List<SimbaInfoData> list = new ArrayList<>();
                        for (int i = 0; i < array.length(); i++) {
                            JSONObject a_jsonObject = array.getJSONObject(i);
                            SimbaInfoData info = new SimbaInfoData();
                            if (!a_jsonObject.isNull("isMust")) {
                                info.setIsMust(a_jsonObject.getString("isMust"));
                            }
                            if (!a_jsonObject.isNull("hint")) {
                                info.setHint(a_jsonObject.getString("hint"));
                            }
                            if (!a_jsonObject.isNull("hint_sw")) {
                                info.setHint_sw(a_jsonObject.getString("hint_sw"));
                            }
                            if (!a_jsonObject.isNull("values")) {
                                JSONArray array1 = a_jsonObject.getJSONArray("values");
                                List<SimbaValueInfo> values = new ArrayList<>();
                                for (int j = 0; j < array1.length(); j++) {
                                    JSONObject v_obj = array1.getJSONObject(j);
                                    SimbaValueInfo bean = new SimbaValueInfo();
                                    if (!v_obj.isNull("title")) {
                                        bean.setTitle(v_obj.getString("title"));
                                    }

                                    if (!v_obj.isNull("value")) {
                                        bean.setValue(v_obj.getString("value"));
                                    }
                                    values.add(bean);
                                }
                                info.setValues(values);
                            }
                            if (!a_jsonObject.isNull("action")) {
                                info.setAction(a_jsonObject.getString("action"));
                            }
                            if (!a_jsonObject.isNull("paramName")) {
                                info.setParamName(a_jsonObject.getString("paramName"));
                            }
                            if (!a_jsonObject.isNull("title")) {
                                info.setTitle(a_jsonObject.getString("title"));
                            }
                            if (!a_jsonObject.isNull("title_sw")) {
                                info.setTitle_sw(a_jsonObject.getString("title_sw"));
                            }
                            list.add(info);
                        }
                        personalInfo.setExtDataList(list);
                    }
                    if (!personal_info.isNull("paramNameDefault")) {
                        personalInfo.setParamNameDefault(personal_info.getString("paramNameDefault"));
                    }
                    mUserProcessBean.setPersonal_info(personalInfo);
                }
                if (!data.isNull("work_info")) {
                    JSONObject work_info = data.getJSONObject("work_info");
                    SimbaWork workInfo = new SimbaWork();
                    if (!work_info.isNull("showTopTips")) {
                        workInfo.setShowTopTips(work_info.getString("showTopTips"));
                    }
                    if (!work_info.isNull("apiUrl")) {
                        workInfo.setApiUrl(work_info.getString("apiUrl"));
                    }
                    if (!work_info.isNull("dataList")) {
                        JSONArray array = work_info.getJSONArray("dataList");
                        List<SimbaInfoData> list = new ArrayList<>();
                        for (int i = 0; i < array.length(); i++) {
                            JSONObject a_jsonObject = array.getJSONObject(i);
                            SimbaInfoData info = new SimbaInfoData();
                            if (!a_jsonObject.isNull("isMust")) {
                                info.setIsMust(a_jsonObject.getString("isMust"));
                            }
                            if (!a_jsonObject.isNull("hint")) {
                                info.setHint(a_jsonObject.getString("hint"));
                            }
                            if (!a_jsonObject.isNull("hint_sw")) {
                                info.setHint_sw(a_jsonObject.getString("hint_sw"));
                            }
                            if (!a_jsonObject.isNull("values")) {
                                JSONArray array1 = a_jsonObject.getJSONArray("values");
                                List<SimbaValueInfo> values = new ArrayList<>();
                                for (int j = 0; j < array1.length(); j++) {
                                    JSONObject v_obj = array1.getJSONObject(j);
                                    SimbaValueInfo bean = new SimbaValueInfo();
                                    if (!v_obj.isNull("title")) {
                                        bean.setTitle(v_obj.getString("title"));
                                    }

                                    if (!v_obj.isNull("value")) {
                                        bean.setValue(v_obj.getString("value"));
                                    }
                                    values.add(bean);
                                }
                                info.setValues(values);
                            }
                            if (!a_jsonObject.isNull("action")) {
                                info.setAction(a_jsonObject.getString("action"));
                            }
                            if (!a_jsonObject.isNull("paramName")) {
                                info.setParamName(a_jsonObject.getString("paramName"));
                            }
                            if (!a_jsonObject.isNull("title")) {
                                info.setTitle(a_jsonObject.getString("title"));
                            }
                            if (!a_jsonObject.isNull("title_sw")) {
                                info.setTitle_sw(a_jsonObject.getString("title_sw"));
                            }
                            list.add(info);
                        }
                        workInfo.setDataList(list);
                    }
                    if (!work_info.isNull("extDataList")) {
                        JSONArray array = work_info.getJSONArray("extDataList");
                        List<SimbaInfoData> list = new ArrayList<>();
                        for (int i = 0; i < array.length(); i++) {
                            JSONObject a_jsonObject = array.getJSONObject(i);
                            SimbaInfoData info = new SimbaInfoData();
                            if (!a_jsonObject.isNull("isMust")) {
                                info.setIsMust(a_jsonObject.getString("isMust"));
                            }
                            if (!a_jsonObject.isNull("hint")) {
                                info.setHint(a_jsonObject.getString("hint"));
                            }
                            if (!a_jsonObject.isNull("hint_sw")) {
                                info.setHint_sw(a_jsonObject.getString("hint_sw"));
                            }
                            if (!a_jsonObject.isNull("values")) {
                                JSONArray array1 = a_jsonObject.getJSONArray("values");
                                List<SimbaValueInfo> values = new ArrayList<>();
                                for (int j = 0; j < array1.length(); j++) {
                                    JSONObject v_obj = array1.getJSONObject(j);
                                    SimbaValueInfo bean = new SimbaValueInfo();
                                    if (!v_obj.isNull("title")) {
                                        bean.setTitle(v_obj.getString("title"));
                                    }

                                    if (!v_obj.isNull("value")) {
                                        bean.setValue(v_obj.getString("value"));
                                    }
                                    values.add(bean);
                                }
                                info.setValues(values);
                            }
                            if (!a_jsonObject.isNull("action")) {
                                info.setAction(a_jsonObject.getString("action"));
                            }
                            if (!a_jsonObject.isNull("paramName")) {
                                info.setParamName(a_jsonObject.getString("paramName"));
                            }
                            if (!a_jsonObject.isNull("title")) {
                                info.setTitle(a_jsonObject.getString("title"));
                            }
                            if (!a_jsonObject.isNull("title_sw")) {
                                info.setTitle_sw(a_jsonObject.getString("title_sw"));
                            }
                            list.add(info);
                        }
                        workInfo.setExtDataList(list);
                    }
                    if (!work_info.isNull("paramNameDefault")) {
                        workInfo.setParamNameDefault(work_info.getString("paramNameDefault"));
                    }
                    mUserProcessBean.setWork_info(workInfo);
                }

                if (!data.isNull("account_info")) {
                    JSONObject account_info = data.getJSONObject("account_info");
                    SimbaAccout accountInfo = new SimbaAccout();
                    if (!account_info.isNull("showTopTips")) {
                        accountInfo.setShowTopTips(account_info.getString("showTopTips"));
                    }
                    if (!account_info.isNull("apiUrl")) {
                        accountInfo.setApiUrl(account_info.getString("apiUrl"));
                    }
                    if (!account_info.isNull("dataList")) {
                        JSONArray array = account_info.getJSONArray("dataList");
                        List<SimbaInfoData> list = new ArrayList<>();
                        for (int i = 0; i < array.length(); i++) {
                            JSONObject a_jsonObject = array.getJSONObject(i);
                            SimbaInfoData info = new SimbaInfoData();
                            if (!a_jsonObject.isNull("isMust")) {
                                info.setIsMust(a_jsonObject.getString("isMust"));
                            }
                            if (!a_jsonObject.isNull("hint")) {
                                info.setHint(a_jsonObject.getString("hint"));
                            }
                            if (!a_jsonObject.isNull("hint_sw")) {
                                info.setHint_sw(a_jsonObject.getString("hint_sw"));
                            }
                            if (!a_jsonObject.isNull("values")) {
                                JSONArray array1 = a_jsonObject.getJSONArray("values");
                                List<SimbaValueInfo> values = new ArrayList<>();
                                for (int j = 0; j < array1.length(); j++) {
                                    JSONObject v_obj = array1.getJSONObject(j);
                                    SimbaValueInfo bean = new SimbaValueInfo();
                                    if (!v_obj.isNull("title")) {
                                        bean.setTitle(v_obj.getString("title"));
                                    }

                                    if (!v_obj.isNull("value")) {
                                        bean.setValue(v_obj.getString("value"));
                                    }
                                    values.add(bean);
                                }
                                info.setValues(values);
                            }
                            if (!a_jsonObject.isNull("action")) {
                                info.setAction(a_jsonObject.getString("action"));
                            }
                            if (!a_jsonObject.isNull("paramName")) {
                                info.setParamName(a_jsonObject.getString("paramName"));
                            }
                            if (!a_jsonObject.isNull("title")) {
                                info.setTitle(a_jsonObject.getString("title"));
                            }
                            if (!a_jsonObject.isNull("title_sw")) {
                                info.setTitle_sw(a_jsonObject.getString("title_sw"));
                            }
                            if (!a_jsonObject.isNull("bankCode")) {
                                info.setBankCode(a_jsonObject.getString("bankCode"));
                            }
                            list.add(info);
                        }
                        accountInfo.setDataList(list);

                    }
                    if (!account_info.isNull("extDataList")) {

                        JSONArray array = account_info.getJSONArray("extDataList");
                        List<SimbaInfoData> list = new ArrayList<>();
                        for (int i = 0; i < array.length(); i++) {
                            JSONObject a_jsonObject = array.getJSONObject(i);
                            SimbaInfoData info = new SimbaInfoData();
                            if (!a_jsonObject.isNull("isMust")) {
                                info.setIsMust(a_jsonObject.getString("isMust"));
                            }
                            if (!a_jsonObject.isNull("hint")) {
                                info.setHint(a_jsonObject.getString("hint"));
                            }
                            if (!a_jsonObject.isNull("hint_sw")) {
                                info.setHint_sw(a_jsonObject.getString("hint_sw"));
                            }
                            if (!a_jsonObject.isNull("values")) {
                                JSONArray array1 = a_jsonObject.getJSONArray("values");
                                List<SimbaValueInfo> values = new ArrayList<>();
                                for (int j = 0; j < array1.length(); j++) {
                                    JSONObject v_obj = array1.getJSONObject(j);
                                    SimbaValueInfo bean = new SimbaValueInfo();
                                    if (!v_obj.isNull("title")) {
                                        bean.setTitle(v_obj.getString("title"));
                                    }

                                    if (!v_obj.isNull("value")) {
                                        bean.setValue(v_obj.getString("value"));
                                    }
                                    values.add(bean);
                                }
                                info.setValues(values);
                            }
                            if (!a_jsonObject.isNull("action")) {
                                info.setAction(a_jsonObject.getString("action"));
                            }
                            if (!a_jsonObject.isNull("paramName")) {
                                info.setParamName(a_jsonObject.getString("paramName"));
                            }
                            if (!a_jsonObject.isNull("title")) {
                                info.setTitle(a_jsonObject.getString("title"));
                            }
                            if (!a_jsonObject.isNull("title_sw")) {
                                info.setTitle_sw(a_jsonObject.getString("title_sw"));
                            }
                            list.add(info);
                        }
                        accountInfo.setExtDataList(list);
                    }
                    if (!account_info.isNull("paramNameDefault")) {
                        accountInfo.setParamNameDefault(account_info.getString("paramNameDefault"));
                    }
                    mUserProcessBean.setAccount_info(accountInfo);
                }

                if (!data.isNull("contact_info")) {
                    JSONObject contact_info = data.getJSONObject("contact_info");
                    SimbaContact contactInfo = new SimbaContact();
                    if (!contact_info.isNull("showTopTips")) {
                        contactInfo.setShowTopTips(contact_info.getString("showTopTips"));
                    }
                    if (!contact_info.isNull("apiUrl")) {
                        contactInfo.setApiUrl(contact_info.getString("apiUrl"));
                    }
                    if (!contact_info.isNull("dataList")) {
                        JSONArray array = contact_info.getJSONArray("dataList");
                        List<SimbaInfoData> list = new ArrayList<>();
                        for (int i = 0; i < array.length(); i++) {
                            JSONObject a_jsonObject = array.getJSONObject(i);
                            SimbaInfoData info = new SimbaInfoData();
                            if (!a_jsonObject.isNull("isMust")) {
                                info.setIsMust(a_jsonObject.getString("isMust"));
                            }
                            if (!a_jsonObject.isNull("hint")) {
                                info.setHint(a_jsonObject.getString("hint"));
                            }
                            if (!a_jsonObject.isNull("hint_sw")) {
                                info.setHint_sw(a_jsonObject.getString("hint_sw"));
                            }
                            if (!a_jsonObject.isNull("values")) {
                                JSONArray array1 = a_jsonObject.getJSONArray("values");
                                List<SimbaValueInfo> values = new ArrayList<>();
                                for (int j = 0; j < array1.length(); j++) {
                                    JSONObject v_obj = array1.getJSONObject(j);
                                    SimbaValueInfo bean = new SimbaValueInfo();
                                    if (!v_obj.isNull("title")) {
                                        bean.setTitle(v_obj.getString("title"));
                                    }

                                    if (!v_obj.isNull("value")) {
                                        bean.setValue(v_obj.getString("value"));
                                    }
                                    values.add(bean);
                                }
                                info.setValues(values);
                            }
                            if (!a_jsonObject.isNull("action")) {
                                info.setAction(a_jsonObject.getString("action"));
                            }
                            if (!a_jsonObject.isNull("paramName")) {
                                info.setParamName(a_jsonObject.getString("paramName"));
                            }
                            if (!a_jsonObject.isNull("title")) {
                                info.setTitle(a_jsonObject.getString("title"));
                            }
                            if (!a_jsonObject.isNull("title_sw")) {
                                info.setTitle_sw(a_jsonObject.getString("title_sw"));
                            }
                            list.add(info);
                        }
                        contactInfo.setDataList(list);
                    }
                    if (!contact_info.isNull("extDataList")) {
                        JSONArray array = contact_info.getJSONArray("extDataList");
                        List<SimbaInfoData> list = new ArrayList<>();
                        for (int i = 0; i < array.length(); i++) {
                            JSONObject a_jsonObject = array.getJSONObject(i);
                            SimbaInfoData info = new SimbaInfoData();
                            if (!a_jsonObject.isNull("isMust")) {
                                info.setIsMust(a_jsonObject.getString("isMust"));
                            }
                            if (!a_jsonObject.isNull("hint")) {
                                info.setHint(a_jsonObject.getString("hint"));
                            }
                            if (!a_jsonObject.isNull("hint_sw")) {
                                info.setHint_sw(a_jsonObject.getString("hint_sw"));
                            }
                            if (!a_jsonObject.isNull("values")) {
                                JSONArray array1 = a_jsonObject.getJSONArray("values");
                                List<SimbaValueInfo> values = new ArrayList<>();
                                for (int j = 0; j < array1.length(); j++) {
                                    JSONObject v_obj = array1.getJSONObject(j);
                                    SimbaValueInfo bean = new SimbaValueInfo();
                                    if (!v_obj.isNull("title")) {
                                        bean.setTitle(v_obj.getString("title"));
                                    }

                                    if (!v_obj.isNull("value")) {
                                        bean.setValue(v_obj.getString("value"));
                                    }
                                    values.add(bean);
                                }
                                info.setValues(values);
                            }
                            if (!a_jsonObject.isNull("action")) {
                                info.setAction(a_jsonObject.getString("action"));
                            }
                            if (!a_jsonObject.isNull("paramName")) {
                                info.setParamName(a_jsonObject.getString("paramName"));
                            }
                            if (!a_jsonObject.isNull("title")) {
                                info.setTitle(a_jsonObject.getString("title"));
                            }
                            if (!a_jsonObject.isNull("title_sw")) {
                                info.setTitle_sw(a_jsonObject.getString("title_sw"));
                            }
                            list.add(info);
                        }
                        contactInfo.setExtDataList(list);
                    }
                    if (!contact_info.isNull("paramNameDefault")) {
                        contactInfo.setParamNameDefault(contact_info.getString("paramNameDefault"));
                    }
                    if (!contact_info.isNull("topTips")) {
                        contactInfo.setTopTips(contact_info.getString("topTips"));
                    }
                    if (!contact_info.isNull("relationShips")) {
                        String relationShips = contact_info.getString("relationShips");
                        Gson gson = new Gson();
                        List<String[]> list = gson.fromJson(relationShips, new TypeToken<List<String[]>>() {
                        }.getType());
                        contactInfo.setRelationShips(list);
                    }
                    if (!contact_info.isNull("relationShips_sw")) {
                        String relationShips = contact_info.getString("relationShips_sw");
                        Gson gson = new Gson();
                        List<String[]> list = gson.fromJson(relationShips, new TypeToken<List<String[]>>() {
                        }.getType());
                        contactInfo.setRelationShips_sw(list);
                    }
                    if (!contact_info.isNull("contactParamName")) {
                        contactInfo.setContactParamName(contact_info.getString("contactParamName"));
                    }
                    if (!contact_info.isNull("isContact")) {
                        contactInfo.setIsContact(contact_info.getString("isContact"));
                    }
                    if (!contact_info.isNull("itemCount")) {
                        contactInfo.setItemCount(contact_info.getInt("itemCount"));
                    }
                    mUserProcessBean.setContact_info(contactInfo);
                }

                if (!data.isNull("steps")) {
                    String allSteps = data.getString("steps");
                    Gson gson = new Gson();
                    String[] list = gson.fromJson(allSteps, String[].class);
                    mUserProcessBean.setSteps(list);
                }
                if (!data.isNull("checkBvn")) {
                    mUserProcessBean.setCheckBvn(data.getString("checkBvn"));
                }
                if (!data.isNull("birthDate")) {
                    mUserProcessBean.setBirthDate(data.getString("birthDate"));
                }
                if (!data.isNull("ocr")) {
                    mUserProcessBean.setOcr(data.getString("ocr"));
                }
                if (!data.isNull("ocrFace")) {
                    mUserProcessBean.setOcrFace(data.getString("ocrFace"));
                }
                if (!data.isNull("ocrCard")) {
                    mUserProcessBean.setOcrCard(data.getString("ocrCard"));
                }
                if (!data.isNull("bindAccount")) {
                    mUserProcessBean.setBindAccount(data.getString("bindAccount"));
                }
                if (!data.isNull("bindCard")) {
                    mUserProcessBean.setBindCard(data.getString("bindCard"));
                }
                if (!data.isNull("isLoan")) {
                    mUserProcessBean.setIsCash(data.getString("isLoan"));
                }
                if (!data.isNull("applyStatus")) {
                    mUserProcessBean.setApplyStatus(data.getString("applyStatus"));
                }
                if (!data.isNull("orderStatus")) {
                    mUserProcessBean.setOrderStatus(data.getString("orderStatus"));
                }
                if (!data.isNull("showGiveUpReasonFlag")) {
                    mUserProcessBean.setShowGiveUpReasonFlag(data.getString("showGiveUpReasonFlag"));
                }
                if (!data.isNull("newApplyPageFlag")) {
                    mUserProcessBean.setNewApplyPageFlag(data.getString("newApplyPageFlag"));
                }
                if (!data.isNull("faceImgAuthFlag")) {
                    mUserProcessBean.setFaceImgAuthFlag(data.getString("faceImgAuthFlag"));
                }
                if (!data.isNull("faceImgAuthSubmitApplyFlag")) {
                    mUserProcessBean.setFaceImgAuthSubmitApplyFlag(data.getString("faceImgAuthSubmitApplyFlag"));
                }
                if (!data.isNull("countDownUserFlag")) {
                    mUserProcessBean.setCountDownUserFlag(data.getString("countDownUserFlag"));
                }
                if (!data.isNull("loanTrialFlag")) {
                    mUserProcessBean.setTrialFlag(data.getString("loanTrialFlag"));
                }
                if (!data.isNull("normalFlag")) {
                    mUserProcessBean.setNormalFlag(data.getString("normalFlag"));
                }
                if (!data.isNull("userType")) {
                    mUserProcessBean.setUserType(data.getString("userType"));
                }
                if (!data.isNull("displayWalletFlag")) {
                    mUserProcessBean.setDisplayWalletFlag(data.getString("displayWalletFlag"));
                }
                if (!data.isNull("walletSwitchFlag")) {
                    mUserProcessBean.setWalletSwitchFlag(data.getString("walletSwitchFlag"));
                }
                if (!data.isNull("signFlag")) {
                    mUserProcessBean.setSignFlag(data.getString("signFlag"));
                }
                if (!data.isNull("signOrderId")) {
                    mUserProcessBean.setSignOrderId(data.getString("signOrderId"));
                }
                if (!data.isNull("whatsappFlag")) {
                    mUserProcessBean.setWhatsappFlag(data.getString("whatsappFlag"));
                }
                if (!data.isNull("smsFlag")) {
                    mUserProcessBean.setSmsFlag(data.getString("smsFlag"));
                }
                if (!data.isNull("mobileEditFlag")) {
                    mUserProcessBean.setMobileEditFlag(data.getString("mobileEditFlag"));
                }

                if (!data.isNull("againApplyDate")) {
                    mUserProcessBean.setAgainApplyDate(data.getString("againApplyDate"));
                }

                if (!data.isNull("fullName")) {
                    mUserProcessBean.setFullName(data.getString("fullName"));
                }

                if (!data.isNull("telegramFlag")) {
                    mUserProcessBean.setTelegramFlag(data.getString("telegramFlag"));
                }

                LogUtil.e("me", mUserProcessBean.getOrderStatus() + "<-applyStatus->" + mUserProcessBean.getApplyStatus());

            }
        } catch (JSONException ignored) {
        }

    }


    public static SimbaLogin userLoginNoCodeJson2Obj(Context context, String json) {
        JSONObject jsonObject;
        SimbaLogin mLoginBean = null;
        try {
            jsonObject = new JSONObject(json);
            if (!jsonObject.isNull("obj") || !jsonObject.isNull("data")) {
                JSONObject data;
                if (!jsonObject.isNull("data")) {
                    data = jsonObject.getJSONObject("data");
                } else {
                    data = jsonObject.getJSONObject("obj");
                }

                if (!data.isNull("token")) {
                    mLoginBean = new SimbaLogin();
                    String token = data.getString("token");
                    U.URL_TOKEN = token;
                    SpUtils.save_string(context, SpUtils.KEY_TOKEN, U.URL_TOKEN);
                    mLoginBean.setToken(token);

                    if (!data.isNull("userId")) {
                        String userId = data.getString("userId");
                        U.URL_USERID = userId;
                        SpUtils.save_string(context, SpUtils.KEY_USERID, U.URL_USERID);
                        mLoginBean.setUserId(userId);
                    }

                    if (!data.isNull("type")) {
                        String type = data.getString("type");
                        SpUtils.save_string(context, SpUtils.KEY_TYPE, type);
                        mLoginBean.setType(type);
                    }

                    if (!data.isNull("isAdSource")) {
                        String isAdSource = data.getString("isAdSource");
                        SpUtils.save_string(context, SpUtils.KEY_ISADSOURCE, isAdSource);
                        mLoginBean.setIsAdSource(isAdSource);
                    }

                }

            }
        } catch (JSONException ignored) {
        }
        return mLoginBean;
    }

    public static String bindBankAccountJson2Obj(String json) {
        String channel = "";
        JSONObject jsonObject;
        try {
            jsonObject = new JSONObject(json);
            if (!jsonObject.isNull("obj") || !jsonObject.isNull("data")) {
                JSONObject data;
                if (!jsonObject.isNull("data")) {
                    data = jsonObject.getJSONObject("data");
                } else {
                    data = jsonObject.getJSONObject("obj");
                }
                String addBindFlag = "NO";
                if (!data.isNull("addBindFlag")) {
                    addBindFlag = data.getString("addBindFlag");
                }
                if (!data.isNull("channel") && addBindFlag.equals("YES")) {
                    channel = data.getString("channel");
                }
            }
        } catch (JSONException ignored) {
        }
        return channel;
    }

    public static String ocrInfoJson2Obj(String json) {
        String token = "";
        JSONObject jsonObject;
        try {
            jsonObject = new JSONObject(json);
            if (!jsonObject.isNull("obj") || !jsonObject.isNull("data")) {
                JSONObject obj;
                if (!jsonObject.isNull("data")) {
                    obj = jsonObject.getJSONObject("data");
                } else {
                    obj = jsonObject.getJSONObject("obj");
                }
                if (!obj.isNull("token")) {
                    token = obj.getString("token");
                }
            }
        } catch (JSONException e) {
            return "";
        }
        return token;
    }

    public static String imageUploadJson2Obj(String json) {
        String url = "";
        JSONObject jsonObject;
        try {
            jsonObject = new JSONObject(json);
            if (!jsonObject.isNull("obj") || !jsonObject.isNull("data")) {
                JSONObject obj;
                if (!jsonObject.isNull("data")) {
                    obj = jsonObject.getJSONObject("data");
                } else {
                    obj = jsonObject.getJSONObject("obj");
                }
                if (!obj.isNull("url")) {
                    url = obj.getString("url");
                }
            }
        } catch (JSONException e) {
            return "";
        }
        return url;
    }

    public static String applyJson2Obj(String json) {
        String orderId = "";
        JSONObject jsonObject;
        try {
            jsonObject = new JSONObject(json);
            if (!jsonObject.isNull("obj") || !jsonObject.isNull("data")) {
                JSONObject obj;
                if (!jsonObject.isNull("data")) {
                    obj = jsonObject.getJSONObject("data");
                } else {
                    obj = jsonObject.getJSONObject("obj");
                }
                if (!obj.isNull("orderId")) {
                    orderId = obj.getString("orderId");
                }
            }
        } catch (JSONException ignored) {
        }
        return orderId;
    }


    public static JSONObject getAbUserInfoJson2Obj(String json) {
        JSONObject jsonObject;
        JSONObject bean = null;
        try {
            jsonObject = new JSONObject(json);
            if (!jsonObject.isNull("obj") || !jsonObject.isNull("data")) {
                JSONObject data;
                if (!jsonObject.isNull("data")) {
                    data = jsonObject.getJSONObject("data");
                } else {
                    data = jsonObject.getJSONObject("obj");
                }

                if (!data.isNull("userInfo")) {
                    String userInfo = data.getString("userInfo");
                    if (userInfo.contains("\\")) {
                        userInfo = userInfo.replaceAll("//", "");
                    }
                    LogUtil.e("me", "userInfo->" + userInfo);
                    bean = new JSONObject(userInfo);
                }

            }
        } catch (JSONException ignored) {
        }
        return bean;
    }


    public static String beforeApplyRiskJson2Obj(String json) {
        JSONObject jsonObject;
        String status = "";
        try {
            jsonObject = new JSONObject(json);
            if (!jsonObject.isNull("obj") || !jsonObject.isNull("data")) {
                JSONObject data;
                if (!jsonObject.isNull("data")) {
                    data = jsonObject.getJSONObject("data");
                } else {
                    data = jsonObject.getJSONObject("obj");
                }

                if (!data.isNull("status")) {
                    status = data.getString("status");
                }

            }
        } catch (JSONException ignored) {
        }
        return status;
    }


    public static void queryDeviceInfoTypes2Obj(String json) {
        JSONObject jsonObject;
        try {
            jsonObject = new JSONObject(json);
            if (!jsonObject.isNull("obj") || !jsonObject.isNull("data")) {
                JSONObject data;

                if (!jsonObject.isNull("data")) {
                    data = jsonObject.getJSONObject("data");
                } else {
                    data = jsonObject.getJSONObject("obj");
                }
                if (!data.isNull("deviceInfoTypes")) {
                    String deviceInfoTypes = data.getString("deviceInfoTypes");
                    Gson gson = new Gson();
                    String[] list = gson.fromJson(deviceInfoTypes, String[].class);
                    SimbaApp.getInstance().setDeviceInfoTypes(list);
                }
            }
        } catch (JSONException e) {
        }
    }

    public static String dropUserDataJson2Obj(String json) {
        JSONObject jsonObject;
        try {
            jsonObject = new JSONObject(json);
            if (!jsonObject.isNull("obj") || !jsonObject.isNull("data")) {
                JSONObject data;

                if (!jsonObject.isNull("data")) {
                    data = jsonObject.getJSONObject("data");
                } else {
                    data = jsonObject.getJSONObject("obj");
                }
                if (!data.isNull("showDropButton")) {
                    String showDropButton = data.getString("showDropButton");
                    return showDropButton;
                }
            }
        } catch (JSONException e) {
        }
        return "";
    }

    public static SimbaAmountIsUpInfo amountIsUpJson2Obj(String json) {
        SimbaAmountIsUpInfo bean = null;
        JSONObject jsonObject;
        try {
            jsonObject = new JSONObject(json);
            if (!jsonObject.isNull("obj") || !jsonObject.isNull("data")) {
                JSONObject data;

                if (!jsonObject.isNull("data")) {
                    data = jsonObject.getJSONObject("data");
                } else {
                    data = jsonObject.getJSONObject("obj");
                }
                bean = new SimbaAmountIsUpInfo();
                if (!data.isNull("openFlag")) {
                    bean.setOpenFlag(data.getString("openFlag"));
                }
                if (!data.isNull("amount")) {
                    bean.setAmount(data.getString("amount"));
                }
                if (!data.isNull("oldAmount")) {
                    bean.setOldAmount(data.getString("oldAmount"));
                }
            }
        } catch (JSONException ignored) {
        }
        return bean;
    }

    public static SimbaProductsAmount loanLimitJson2Obj(String json) {
        JSONObject jsonObject;
        SimbaProductsAmount productsAmount = null;
        try {
            jsonObject = new JSONObject(json);
            if (!jsonObject.isNull("obj") || !jsonObject.isNull("data")) {
                JSONObject data;
                if (!jsonObject.isNull("data")) {
                    data = jsonObject.getJSONObject("data");
                } else {
                    data = jsonObject.getJSONObject("obj");
                }

                if (!data.isNull("limit")) {
                    JSONArray array = data.getJSONArray("limit");
                    if (array.length() > 0) {
                        productsAmount = new SimbaProductsAmount();
                        JSONObject jsonObject1 = array.getJSONObject(0);
                        if (!jsonObject1.isNull("amount")) {
                            productsAmount.setAmount(jsonObject1.getString("amount"));
                        }
                        if (!jsonObject1.isNull("increasedAmount1")) {
                            productsAmount.setIncreasedAmount1(jsonObject1.getString("increasedAmount1"));
                        }
                        if (!jsonObject1.isNull("increasedAmount2")) {
                            productsAmount.setIncreasedAmount2(jsonObject1.getString("increasedAmount2"));
                        }
                        if (!jsonObject1.isNull("currency")) {
                            productsAmount.setCurrency(jsonObject1.getString("currency"));
                        }
                    }
                }


            }
        } catch (JSONException ignored) {
        }
        return productsAmount;
    }

    public static List<SimbaAccountItem> fetchBoundBankAccountJson2Obj(String json) {
        List<SimbaAccountItem> list = null;
        JSONObject jsonObject;
        try {
            jsonObject = new JSONObject(json);
            if (!jsonObject.isNull("obj") || !jsonObject.isNull("data")) {
                list = new ArrayList<>();
                JSONArray array;
                if (!jsonObject.isNull("data")) {
                    array = jsonObject.getJSONArray("data");
                } else {
                    array = jsonObject.getJSONArray("obj");
                }
                for (int i = 0; i < array.length(); i++) {
                    JSONObject data = array.getJSONObject(i);
                    SimbaAccountItem cardInfo = new SimbaAccountItem();
                    if (data != null && !data.isNull("id")) {
                        cardInfo.setId(data.getString("id"));
                    }
                    if (data != null && !data.isNull("walletDesc")) {
                        cardInfo.setWalletDesc(data.getString("walletDesc"));
                    }
                    if (data != null && !data.isNull("walletMobile")) {
                        cardInfo.setWalletMobile(data.getString("walletMobile"));
                    }
                    if (data != null && !data.isNull("walletLogo")) {
                        cardInfo.setWalletLogo(data.getString("walletLogo"));
                    }
                    cardInfo.setData(true);
                    list.add(cardInfo);
                }

            }
        } catch (JSONException ignored) {
        }
        return list;
    }


    public static SimbaScoreInfo fetchStarWindowConfigJson2Obj(String json) {
        SimbaScoreInfo bean = null;
        JSONObject jsonObject;
        try {
            jsonObject = new JSONObject(json);
            if (!jsonObject.isNull("obj") || !jsonObject.isNull("data")) {
                JSONObject data;

                if (!jsonObject.isNull("data")) {
                    data = jsonObject.getJSONObject("data");
                } else {
                    data = jsonObject.getJSONObject("obj");
                }
                if (!data.isNull("normalWindow")) {
                    bean = new SimbaScoreInfo();
                    JSONObject normalWindow = data.getJSONObject("normalWindow");
                    if (!normalWindow.isNull("num")) {
                        bean.setNum(normalWindow.getInt("num"));
                    }
                    if (!normalWindow.isNull("content")) {
                        bean.setContent(normalWindow.getString("content"));
                    }
                    if (!normalWindow.isNull("switch")) {
                        bean.setSwitch_data(normalWindow.getString("switch"));
                    }
                }

            }
        } catch (JSONException ignored) {
        }
        return bean;
    }

    public static SimbaApplyDetailInfo getDetailPageForDaysJson2Obj(String json) {
        SimbaApplyDetailInfo applyDetail = null;
        JSONObject jsonObject;
        try {
            jsonObject = new JSONObject(json);
            if (!jsonObject.isNull("data") || !jsonObject.isNull("obj")) {
                JSONObject data;
                if (!jsonObject.isNull("data")) {
                    data = jsonObject.getJSONObject("data");
                } else {
                    data = jsonObject.getJSONObject("obj");
                }
                applyDetail = new SimbaApplyDetailInfo();
                if (!data.isNull("daysArray")) {
                    String daysArray = data.getString("daysArray");
                    Gson gson = new Gson();
                    String[] list = gson.fromJson(daysArray, String[].class);
                    applyDetail.setDaysArray(list);
                }
                if (!data.isNull("detailItemList")) {
                    JSONArray array = data.getJSONArray("detailItemList");
                    List<SimbaDetailItemInfo> detailItemList = new ArrayList<>();
                    for (int i = 0; i < array.length(); i++) {
                        JSONObject d_jsonObject = array.getJSONObject(i);
                        SimbaDetailItemInfo bean = new SimbaDetailItemInfo();
                        if (!d_jsonObject.isNull("title")) {
                            bean.setTitle(d_jsonObject.getString("title"));
                        }
                        if (!d_jsonObject.isNull("showName")) {
                            bean.setShowName(d_jsonObject.getString("showName"));
                        }
                        if (!d_jsonObject.isNull("showDetail")) {
                            bean.setShowDetail(d_jsonObject.getString("showDetail"));
                        }
                        if (!d_jsonObject.isNull("oldDetail")) {
                            bean.setOldDetail(d_jsonObject.getString("oldDetail"));

                        }
                        if (!d_jsonObject.isNull("discount")) {
                            bean.setDiscount(d_jsonObject.getString("discount"));

                        }

                        detailItemList.add(bean);
                    }
                    applyDetail.setDetailItemList(detailItemList);
                }

                if (!data.isNull("amount")) {
                    applyDetail.setAmount(NumUtils.str2Int(data.getString("amount")));
                }

                if (!data.isNull("days")) {
                    applyDetail.setDays(data.getString("days"));
                }

                if (!data.isNull("chooseAmountFlag")) {
                    applyDetail.setChooseAmountFlag(data.getBoolean("chooseAmountFlag"));
                }

                if (!data.isNull("maxAmount")) {
                    applyDetail.setMaxAmount(NumUtils.str2Int(data.getString("maxAmount")));
                }

                if (!data.isNull("minAmoun")) {
                    applyDetail.setMinAmoun(NumUtils.str2Int(data.getString("minAmoun")));
                }

                if (!data.isNull("minAmount")) {
                    applyDetail.setMinAmoun(NumUtils.str2Int(data.getString("minAmount")));
                }

                if (!data.isNull("granularity")) {
                    applyDetail.setGranularity(NumUtils.str2Int(data.getString("granularity")));
                }

            }
        } catch (JSONException ignored) {
        }
        return applyDetail;
    }

    public static SimbaDetailInfo getApplyDetailJson2Obj(String json) {
        SimbaDetailInfo mDetailBean = null;
        JSONObject jsonObject;
        try {
            jsonObject = new JSONObject(json);

            if (!jsonObject.isNull("data") || !jsonObject.isNull("obj")) {
                mDetailBean = new SimbaDetailInfo();
                JSONObject data;
                if (!jsonObject.isNull("data")) {
                    data = jsonObject.getJSONObject("data");
                } else {
                    data = jsonObject.getJSONObject("obj");
                }
                if (!data.isNull("detailItemList")) {
                    JSONArray array = data.getJSONArray("detailItemList");
                    List<SimbaDetailItemInfo> list = new ArrayList<>();
                    for (int i = 0; i < array.length(); i++) {
                        JSONObject d_jsonObject = array.getJSONObject(i);
                        SimbaDetailItemInfo bean = new SimbaDetailItemInfo();
                        if (!d_jsonObject.isNull("title")) {
                            bean.setTitle(d_jsonObject.getString("title"));
                        }
                        if (!d_jsonObject.isNull("showName")) {
                            bean.setShowName(d_jsonObject.getString("showName"));
                        }
                        if (!d_jsonObject.isNull("showDetail")) {
                            bean.setShowDetail(d_jsonObject.getString("showDetail"));
                        }
                        if (!d_jsonObject.isNull("oldDetail")) {
                            bean.setOldDetail(d_jsonObject.getString("oldDetail"));
                        }
                        if (!d_jsonObject.isNull("discount")) {
                            bean.setDiscount(d_jsonObject.getString("discount"));
                        }
                        list.add(bean);
                    }
                    mDetailBean.setDetailItemList(list);

                }

                if (!data.isNull("amount")) {
                    mDetailBean.setAmount(data.getString("amount"));
                }

                if (!data.isNull("days")) {
                    mDetailBean.setDays(data.getString("days"));
                }

                if (!data.isNull("realAmount")) {
                    mDetailBean.setRealAmount(data.getString("realAmount"));
                }

                if (!data.isNull("processingFee")) {
                    mDetailBean.setProcessingFee(data.getString("processingFee"));
                }

                if (!data.isNull("processingVatFee")) {
                    mDetailBean.setProcessingVatFee(data.getString("processingVatFee"));
                }

                if (!data.isNull("repayAmount")) {
                    mDetailBean.setRepayAmount(data.getString("repayAmount"));
                }

                if (!data.isNull("repayProFee")) {
                    mDetailBean.setRepayProFee(data.getString("repayProFee"));
                }

                if (!data.isNull("repayProVatFee")) {
                    mDetailBean.setRepayProVatFee(data.getString("repayProVatFee"));
                }

                if (!data.isNull("interest")) {
                    mDetailBean.setInterest(data.getString("interest"));
                }

                if (!data.isNull("interestRate")) {
                    mDetailBean.setInterestRate(data.getString("interestRate"));
                }

                if (!data.isNull("overdueRate")) {
                    mDetailBean.setOverdueRate(data.getString("overdueRate"));
                }

                if (!data.isNull("currency")) {
                    mDetailBean.setCurrency(data.getString("currency"));
                }

            }
        } catch (JSONException ignored) {
        }

        return mDetailBean;
    }

    public static List<SimbaAccountItem> getBindCardListJson2Obj(String json) {
        List<SimbaAccountItem> list = null;
        JSONObject jsonObject;
        try {
            jsonObject = new JSONObject(json);
            if (!jsonObject.isNull("obj") || !jsonObject.isNull("data")) {
                list = new ArrayList<>();
                JSONArray array;
                if (!jsonObject.isNull("data")) {
                    array = jsonObject.getJSONArray("data");
                } else {
                    array = jsonObject.getJSONArray("obj");
                }
                for (int i = 0; i < array.length(); i++) {
                    JSONObject data = array.getJSONObject(i);
                    SimbaAccountItem cardInfo = new SimbaAccountItem();
                    if (data != null && !data.isNull("name")) {
                        cardInfo.setWalletDesc(data.getString("name"));
                    }
                    if (data != null && !data.isNull("account")) {
                        cardInfo.setWalletMobile(data.getString("account"));
                    }
                    if (data != null && !data.isNull("logo")) {
                        cardInfo.setWalletLogo(data.getString("logo"));
                    }
                    cardInfo.setData(true);
                    list.add(cardInfo);
                }

            }
        } catch (JSONException e) {
        }
        return list;
    }

    public static SimbaRepayInfo repayInfoJson2Obj(String json) {
        SimbaRepayInfo repayInfo = null;
        JSONObject jsonObject;
        try {
            jsonObject = new JSONObject(json);
            if (!jsonObject.isNull("obj") || !jsonObject.isNull("data")) {
                JSONObject data;
                repayInfo = new SimbaRepayInfo();
                if (!jsonObject.isNull("data")) {
                    data = jsonObject.getJSONObject("data");
                } else {
                    data = jsonObject.getJSONObject("obj");
                }
                if (!data.isNull("amount")) {
                    repayInfo.setAmount(data.getString("amount"));
                }
                if (!data.isNull("days")) {
                    repayInfo.setDays(data.getString("days"));
                }
                if (!data.isNull("remainDay")) {
                    repayInfo.setRemainDay(data.getString("remainDay"));
                }
                if (!data.isNull("interest")) {
                    repayInfo.setInterest(data.getString("interest"));
                }
                if (!data.isNull("serviceFee")) {
                    repayInfo.setServiceFee(data.getString("serviceFee"));
                }
                if (!data.isNull("serviceVatFee")) {
                    repayInfo.setServiceVatFee(data.getString("serviceVatFee"));
                }
                if (!data.isNull("repayAmount")) {
                    repayInfo.setRepayAmount(data.getString("repayAmount"));
                }
                if (!data.isNull("repayDate")) {
                    repayInfo.setRepayDate(data.getString("repayDate"));
                }
                if (!data.isNull("repayProFee")) {
                    repayInfo.setRepayProFee(data.getString("repayProFee"));
                }
                if (!data.isNull("repayProVatFee")) {
                    repayInfo.setRepayProVatFee(data.getString("repayProVatFee"));
                }
                if (!data.isNull("overdueAmount")) {
                    repayInfo.setOverdueAmount(data.getString("overdueAmount"));
                }
                if (!data.isNull("overdueDay")) {
                    repayInfo.setOverdueDay(data.getString("overdueDay"));
                }
                if (!data.isNull("currency")) {
                    repayInfo.setCurrency(data.getString("currency"));
                }
                if (!data.isNull("partRepayFlag")) {
                    repayInfo.setPartRepayFlag(data.getString("partRepayFlag"));
                }
                if (!data.isNull("deferredFlag")) {
                    repayInfo.setDeferredFlag(data.getString("deferredFlag"));
                }
                if (!data.isNull("remainRepayDay")) {
                    repayInfo.setRemainRepayDay(data.getString("remainRepayDay"));
                }
                if (!data.isNull("detailItemList")) {
                    JSONArray array = data.getJSONArray("detailItemList");
                    List<SimbaDetailItemInfo> list = new ArrayList<>();
                    for (int i = 0; i < array.length(); i++) {
                        JSONObject d_jsonObject = array.getJSONObject(i);
                        SimbaDetailItemInfo bean = new SimbaDetailItemInfo();
                        if (!d_jsonObject.isNull("title")) {
                            bean.setTitle(d_jsonObject.getString("title"));
                        }
                        if (!d_jsonObject.isNull("showName")) {
                            bean.setShowName(d_jsonObject.getString("showName"));
                        }
                        if (!d_jsonObject.isNull("showDetail")) {
                            bean.setShowDetail(d_jsonObject.getString("showDetail"));
                        }
                        if (!d_jsonObject.isNull("oldDetail")) {
                            bean.setOldDetail(d_jsonObject.getString("oldDetail"));
                        }
                        if (!d_jsonObject.isNull("discount")) {
                            bean.setDiscount(d_jsonObject.getString("discount"));
                        }
                        list.add(bean);
                    }
                    repayInfo.setDetailItemList(list);
                }
            }
        } catch (JSONException ignored) {
        }
        return repayInfo;
    }


    public static SimbaOrderRepayInfo getOrderRepayH5Json2Obj(String json) {
        SimbaOrderRepayInfo bean = null;
        JSONObject jsonObject;
        try {
            jsonObject = new JSONObject(json);
            if (!jsonObject.isNull("obj") || !jsonObject.isNull("data")) {
                JSONObject data;
                bean = new SimbaOrderRepayInfo();
                if (!jsonObject.isNull("data")) {
                    data = jsonObject.getJSONObject("data");
                } else {
                    data = jsonObject.getJSONObject("obj");
                }
                if (!data.isNull("repayUrl")) {
                    bean.setRepayUrl(data.getString("repayUrl"));
                }
                if (!data.isNull("orderId")) {
                    bean.setOrderId(data.getString("orderId"));
                }
                if (!data.isNull("thirdOrderId")) {
                    bean.setThirdOrderId(data.getString("thirdOrderId"));
                }
                if (!data.isNull("url")) {
                    bean.setUrl(data.getString("url"));
                }

            }
        } catch (JSONException ignored) {
        }
        return bean;
    }

    public static SimbaOrderRepayState queryPaymentStatusJson2Obj(String json) {
        SimbaOrderRepayState bean = null;
        JSONObject jsonObject;
        try {
            jsonObject = new JSONObject(json);
            if (!jsonObject.isNull("obj") || !jsonObject.isNull("data")) {
                JSONObject data;
                bean = new SimbaOrderRepayState();
                if (!jsonObject.isNull("data")) {
                    data = jsonObject.getJSONObject("data");
                } else {
                    data = jsonObject.getJSONObject("obj");
                }
                if (!data.isNull("product")) {
                    bean.setProduct(data.getString("product"));
                }
                if (!data.isNull("amount")) {
                    bean.setAmount(data.getString("amount"));
                }
                if (!data.isNull("realRepayAmount")) {
                    bean.setRealRepayAmount(data.getString("realRepayAmount"));
                }
                if (!data.isNull("transactionId")) {
                    bean.setTransactionId(data.getString("transactionId"));
                }
                if (!data.isNull("createTime")) {
                    bean.setCreateTime(data.getString("createTime"));
                }
                if (!data.isNull("realRepayTime")) {
                    bean.setRealRepayTime(data.getString("realRepayTime"));
                }
                if (!data.isNull("failedTime")) {
                    bean.setFailedTime(data.getString("failedTime"));
                }
                if (!data.isNull("status")) {
                    bean.setStatus(data.getString("status"));
                }

            }
        } catch (JSONException ignored) {
        }
        return bean;
    }


    public static List<SimbaChatInfo> feedbackTalkJson2Obj(String json) {
        JSONObject jsonObject;
        List<SimbaChatInfo> list = null;
        try {
            jsonObject = new JSONObject(json);
            if (!jsonObject.isNull("obj") || !jsonObject.isNull("data")) {
                JSONArray array;
                if (!jsonObject.isNull("data")) {
                    array = jsonObject.getJSONArray("data");
                } else {
                    array = jsonObject.getJSONArray("obj");
                }
                if (array.length() > 0) {
                    list = new ArrayList<>();
                    for (int i = 0; i < array.length(); i++) {
                        SimbaChatInfo chat = new SimbaChatInfo();
                        JSONObject jsonObject1 = array.getJSONObject(i);
                        if (!jsonObject1.isNull("searchValue")) {
                            chat.setSearchValue(jsonObject1.getString("searchValue"));
                        }
                        if (!jsonObject1.isNull("createBy")) {
                            chat.setCreateBy(jsonObject1.getString("createBy"));
                        }
                        if (!jsonObject1.isNull("createTime")) {
                            chat.setCreateTime(jsonObject1.getString("createTime"));
                        }
                        if (!jsonObject1.isNull("updateBy")) {
                            chat.setUpdateBy(jsonObject1.getString("updateBy"));
                        }
                        if (!jsonObject1.isNull("updateTime")) {
                            chat.setUpdateTime(jsonObject1.getString("updateTime"));
                        }
                        if (!jsonObject1.isNull("remark")) {
                            chat.setRemark(jsonObject1.getString("remark"));
                        }
                        if (!jsonObject1.isNull("id")) {
                            chat.setId(jsonObject1.getInt("id"));
                        }
                        if (!jsonObject1.isNull("product")) {
                            chat.setProduct(jsonObject1.getString("product"));
                        }
                        if (!jsonObject1.isNull("mobile")) {
                            chat.setMobile(jsonObject1.getString("mobile"));
                        }
                        if (!jsonObject1.isNull("userId")) {
                            chat.setUserId(jsonObject1.getString("userId"));
                        }
                        if (!jsonObject1.isNull("talkInfo")) {
                            chat.setTalkInfo(jsonObject1.getString("talkInfo"));
                        }
                        if (!jsonObject1.isNull("sysUserId")) {
                            chat.setSysUserId(jsonObject1.getString("sysUserId"));
                        }
                        if (!jsonObject1.isNull("talkType")) {
                            chat.setTalkType(jsonObject1.getString("talkType"));
                        }
                        if (!jsonObject1.isNull("createTimeStamp")) {
                            chat.setCreateTimeStamp(jsonObject1.getString("createTimeStamp"));
                        }
                        chat.setState(1);
                        list.add(chat);
                    }
                }
            }
        } catch (JSONException ignored) {
        }
        return list;
    }

    public static SimbaMessageInfo sendWhatAppMessageJson2Obj(String json) {
        SimbaMessageInfo smsCodeBean = null;
        try {
            JSONObject jsonObject = new JSONObject(json);
            if (!jsonObject.isNull("obj") || !jsonObject.isNull("data")) {
                JSONObject data;
                if (!jsonObject.isNull("data")) {
                    data = jsonObject.getJSONObject("data");
                } else {
                    data = jsonObject.getJSONObject("obj");
                }
                if (!data.isNull("directLoginFlag")) {
                    smsCodeBean = new SimbaMessageInfo();
                    if (!data.isNull("directLoginFlag")) {
                        String directLoginFlag = data.getString("directLoginFlag");
                        smsCodeBean.setDirectLoginFlag(directLoginFlag);
                    }
                    if (!data.isNull("needSubmitBirthDay")) {
                        String needSubmitBirthDay = data.getString("needSubmitBirthDay");
                        smsCodeBean.setNeedSubmitBirthDay(needSubmitBirthDay);
                    }
                }
            }
        } catch (JSONException ignored) {
        }
        return smsCodeBean;
    }

    public static String fetchTelegramBotUrlJson2Obj(String json) {
        JSONObject jsonObject;
        try {
            jsonObject = new JSONObject(json);
            if (!jsonObject.isNull("obj") || !jsonObject.isNull("data")) {
                JSONObject data;

                if (!jsonObject.isNull("data")) {
                    data = jsonObject.getJSONObject("data");
                } else {
                    data = jsonObject.getJSONObject("obj");
                }
                if (!data.isNull("url")) {
                    return data.getString("url");
                }
            }
        } catch (JSONException e) {
        }
        return "";
    }

    public static List<SimbaValueInfo> fetchBankCodesJson2Obj(String json) {
        JSONObject jsonObject;
        List<SimbaValueInfo> valueInfoList = null;
        try {
            jsonObject = new JSONObject(json);
            if (!jsonObject.isNull("obj") || !jsonObject.isNull("data")) {
                JSONArray data;

                if (!jsonObject.isNull("data")) {
                    data = jsonObject.getJSONArray("data");
                } else {
                    data = jsonObject.getJSONArray("obj");
                }

                if (data.length() > 0) {
                    valueInfoList = new ArrayList<>();
                    for (int i = 0; i < data.length(); i++) {
                        SimbaValueInfo valueInfo = new SimbaValueInfo();

                        JSONObject jsonObject1 = data.getJSONObject(i);
                        if (!jsonObject1.isNull("bankCode")) {
                            valueInfo.setValue1(jsonObject1.getString("bankCode"));
                        }
                        if (!jsonObject1.isNull("bankName")) {
                            valueInfo.setTitle(jsonObject1.getString("bankName"));
                            valueInfo.setValue(valueInfo.getTitle());
                        }
                        valueInfoList.add(valueInfo);
                    }
                }

            }
        } catch (JSONException e) {
        }
        return valueInfoList;
    }

}
